package com.cn.gmall.weball.controller;

import com.cn.gmall.model.product.SkuInfo;
import com.cn.gmall.product.client.ProductFeignClient;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@SuppressWarnings("all")
public class CartController {

    @Autowired
    private ProductFeignClient productFeignClient;

    @GetMapping("cart.html")
    public String cartList() {

        return "cart/index";
    }


    /***
     * 加入购物车
     * @param skuId
     * @param skuNum
     * @return
     */
    @GetMapping("/addCart.html")
    public String addCart(@RequestParam Long skuId, @RequestParam Long skuNum, Model model) {
//         获取skuInfo信息
        SkuInfo skuInfo = productFeignClient.getSkuInfo(skuId);
//             设置响应
        model.addAttribute("skuInfo", skuInfo);
        model.addAttribute("skuNum", skuNum);


        return "cart/addCart";
    }


}
